package sender

import (
	hook "github.com/robotn/gohook"
	"mks/message"
	"net"
)

/*
send 是指有鼠标键盘输入的这设备端
*/

func NewMessageFromEvent(event *hook.Event) *message.MouseMessage {
	return &message.MouseMessage{
		Kind:      event.Kind,
		X:         event.X,
		Y:         event.Y,
		Button:    event.Button,
		Code:      event.Keycode,
		Direction: event.Direction,
		Rotation:  event.Rotation,
	}
}
func ConnectToClient(host string) {
	addr, e := net.ResolveUDPAddr("udp4", host)
	if e != nil {
		panic(e)
	}
	conn, e := net.DialUDP("udp", nil, addr)
	if e != nil {
		panic(e)
	}
	defer conn.Close()
	WatchKeyboard(conn)
}
